package com.sevenGroup.pawnshop.dao;

import com.sevenGroup.pawnshop.model.Function;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author sevenGroup
 * @since 2022-02-16
 */
public interface FunctionDao extends BaseMapper<Function> {
//    通过角色ID查询功能集合
    @Select("SELECT f.function_id,f.function_name,f.function_icon,f.function_isleaf,f.function_URL,f.function_leaf_id,f.function_index FROM  permission p JOIN `function` f ON f.function_id=p.function_id WHERE p.role_id=#{rid}")
    @Results(id = "Function",value = {
            @Result(column = "function_id",property = "functionId"),
            @Result(column = "function_name",property = "functionName"),
            @Result(column = "function_icon",property = "functionIcon"),
            @Result(column = "function_isleaf",property = "functionIsleaf"),
            @Result(column = "function_URL",property = "functionUrl"),
            @Result(column = "function_leaf_id",property = "functionLeafId"),
            @Result(column = "function_index",property = "functionIndex")
    })
    List<Function> getFunctionByRoleId(Integer rid);
}
